#
# amarokSyndication - Amarok script for syndicating (atom file format) your music to Google Pages
#
# $Id: amarokSyndication.pl 2008-05-10 19:15:51Z meff $
#
# (C) 2007,2008 Diego Pino  <pinowsky at gmail com>
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
#

##
# Provides functions for grabbing Amarok information for feeding later atom entries
#

sub DCOPGrab {
    my $dcopline = shift;

    my $dcopreturn = qx{ dcop $dcopline };
    chomp($dcopreturn);

    return $dcopreturn;
}

sub GetTime
{
   ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);

   return sprintf("%4d-%02d-%02dT%02d:%02d:%02dZ",
		$year+1900,$mon+1,$mday,$hour,$min,$sec);
}

sub GetMusicInfo
{
    my $nowPlaying;

        # artist and title
    $nowPlaying = DCOPGrab('amarok player nowPlaying');
    ($data{'artist'}, $data{'title'}) = split(/-/, $nowPlaying);

        # album
    $data{'artist'} = &trim($data{'artist'});
    $data{'title'} = &trim($data{'title'});
    $data{'album'} = DCOPGrab('amarok player album');

    return %data;
}

1;
